﻿<UserControl x:Class="XmlStudio.Resources.UserControls.UcXsdAttributes"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:uc="clr-namespace:XmlStudio.Resources.UserControls" 
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300"
             x:Name="ucXsdAttributes">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>

        <ItemsControl x:Name="attributesItemsControl" Grid.Row="0" ItemsSource="{Binding Attributes}">
            <!--ItemTemplate="{Binding ElementName=ucXsdAttributes, Path=ItemTemplate}"-->
            <ItemsControl.Template>
                <ControlTemplate>
                    <ScrollViewer VerticalScrollBarVisibility="Auto" CanContentScroll="False">
                        <StackPanel IsItemsHost="True" />
                    </ScrollViewer>
                </ControlTemplate>
            </ItemsControl.Template>
            <ItemsControl.ItemTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="{Binding Prefix}" Height="{StaticResource TextBlockHeight}" MinWidth="15" />
                        <TextBlock Text=":" Height="{StaticResource TextBlockHeight}" />
                        <TextBlock Text="{Binding LocalName}" Height="{StaticResource TextBlockHeight}" MinWidth="50" />
                        <TextBox Text="{Binding Value}" MinWidth="100" Margin="{StaticResource TextBoxMargin}" 
                                    Height="{StaticResource TextBoxHeight}" IsReadOnly="True" />
                        <Button HorizontalAlignment="Right" BorderThickness="0" Background="Transparent" Width="15" Height="15" 
                                Command="uc:UcXsdAttributes.EditAttribute" CommandParameter="{Binding}">
                            <Image Source="pack://application:,,,/Icons/edit.ico" />
                        </Button>
                        <Button HorizontalAlignment="Right" BorderThickness="0" Background="Transparent" Width="15" Height="15" 
                                Command="uc:UcXsdAttributes.RemoveAttribute" CommandParameter="{Binding}" Visibility="{Binding Required, Converter={StaticResource boolToVisibilityNegativeConverter}}">
                            <Image Source="pack://application:,,,/Icons/edit_remove.ico" />
                        </Button>
                    </StackPanel>
                </DataTemplate>
            </ItemsControl.ItemTemplate>
        </ItemsControl>

        <Button Visibility="{Binding ElementName=ucAttributes, Path=ReadOnly, Converter={StaticResource boolToVisibilityNegativeConverter}}" 
                HorizontalAlignment="Right" Grid.Row="1" BorderThickness="0" Background="Transparent" Width="15" Height="15" Click="Button_Click">
            <Image Source="pack://application:,,,/Icons/edit_add.ico" />
        </Button>
    </Grid>
</UserControl>
